﻿using DDHDeepTunnel.Interfaces;
using WebFoundation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.IO;
using System.Xml.Serialization;

namespace DDHDeepTunnel.WebApi
{
    /// <summary>
    /// Monitor Information query and writing
    /// </summary>
    [RoutePrefix("api/MonitorInformation/MonitorInformationAnalysis")]
    public class MonitorInformationController : WFApiController
    {
        [WFAutoLoad]
        public IDDHDeepTunnelModule ddhDeepTunnelModule { get; set; }

        [WFAutoLoad]
        public IOnlineDataModule onlineDataModule { get; set; }

        #region Get 测试数据
        
        /// <summary>
        /// 获取全部日志数据信息
        /// </summary>
        [HttpGet]
        [Route("GetAllSystemLog/")]
        [Description("获取全部日志数据信息")]
        public async Task<List<SystemLog>> GetAllSystemLog()
        {
            using (onlineDataModule)
            {
                List<SystemLog> systemLogs = new List<SystemLog>();
                string objectId = string.Empty;
                systemLogs = onlineDataModule.SystemLogInfos.GetAllSystemLogInfo().ToList();
                return await Task.Run(() => systemLogs);
            }
        }

        /// <summary>
        /// 获取日志数据信息
        /// </summary>
        [HttpGet]
        [Route("GetSystemLogByLogType/")]
        [Description("获取日志数据信息")]
        public async Task<List<SystemLog>> GetSystemLogByLogType(string logType)
        {
            using (onlineDataModule)
            {
                List<SystemLog> systemLogs = new List<SystemLog>();
                string objectId = string.Empty;
                systemLogs = onlineDataModule.SystemLogInfos.GetSystemLogInfoByLogType(logType).ToList();
                return await Task.Run(() => systemLogs);
            }
        }

        #endregion     
    }
}
